package com.jeewms.www.tms.util;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by 13799 on 2018/9/21.
 */

public class OkHttpUtil {

    public static void get(String url,final OkHttpListener listener){
        OkHttpClient okHttpClient = new OkHttpClient();
        final Request request = new Request.Builder().url(url).get().build();
        Call call = okHttpClient.newCall(request);
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                listener.onFailure();
            }
            @Override
            public void onResponse(Call call, Response response) throws IOException {
                listener.onResponse(response.body().toString());
            }
        });
    }
}
